package com.comando.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.GenericGenerator;

/**
 * UserT entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user_t", catalog = "qunar", uniqueConstraints = {
		@UniqueConstraint(columnNames = "LOGIN_NAME"),
		@UniqueConstraint(columnNames = "EMAIL") })
public class UserT implements java.io.Serializable {

	// Fields

	private Integer userId;
	private String loginName;
	private String password;
	private String email;
	private Timestamp createTime;
	private Timestamp lastLoginTime;
	private String lastLoginIp;
	private Timestamp currentLoginTime;
	private String currentLoginIp;
	private Long loginCount;
	private String state;
	//private Set<ArticleT> articleTs = new HashSet<ArticleT>(0);
	private UserRoleT userRoleT;
	//private Set<CommentT> commentTs = new HashSet<CommentT>(0);
	private Set<UserInfoT> userInfoTs = new HashSet<UserInfoT>(0);
	private UserMemberT userMemberT;

	// Constructors

	/** default constructor */
	public UserT() {
	}

	/** minimal constructor */
	public UserT(String loginName, String email, String state) {
		this.loginName = loginName;
		this.email = email;
		this.state = state;
	}

	/** full constructor */
	public UserT(String loginName, String password,
			String email, Timestamp createTime, Timestamp lastLoginTime,
			String lastLoginIp, Timestamp currentLoginTime,
			String currentLoginIp, Long loginCount, String state,
			Set<ArticleT> articleTs, UserRoleT userRoleT,
			//Set<CommentT> commentTs, Set<UserInfoT> userInfoTs,
			UserMemberT userMemberT) {
		this.loginName = loginName;
		this.password = password;
		this.email = email;
		this.createTime = createTime;
		this.lastLoginTime = lastLoginTime;
		this.lastLoginIp = lastLoginIp;
		this.currentLoginTime = currentLoginTime;
		this.currentLoginIp = currentLoginIp;
		this.loginCount = loginCount;
		this.state = state;
		//this.articleTs = articleTs;
		this.userRoleT = userRoleT;
		//this.commentTs = commentTs;
		this.userInfoTs = userInfoTs;
		this.userMemberT = userMemberT;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "USER_ID", unique = true, nullable = false)
	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@Column(name = "LOGIN_NAME", unique = true, nullable = false, length = 50)
	public String getLoginName() {
		return this.loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	@Column(name = "PASSWORD", length = 32)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "EMAIL", unique = true, nullable = false, length = 100)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "CREATE_TIME", length = 19)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@Column(name = "LAST_LOGIN_TIME", length = 19)
	public Timestamp getLastLoginTime() {
		return this.lastLoginTime;
	}

	public void setLastLoginTime(Timestamp lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	@Column(name = "LAST_LOGIN_IP", length = 50)
	public String getLastLoginIp() {
		return this.lastLoginIp;
	}

	public void setLastLoginIp(String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}

	@Column(name = "CURRENT_LOGIN_TIME", length = 19)
	public Timestamp getCurrentLoginTime() {
		return this.currentLoginTime;
	}

	public void setCurrentLoginTime(Timestamp currentLoginTime) {
		this.currentLoginTime = currentLoginTime;
	}

	@Column(name = "CURRENT_LOGIN_IP", length = 50)
	public String getCurrentLoginIp() {
		return this.currentLoginIp;
	}

	public void setCurrentLoginIp(String currentLoginIp) {
		this.currentLoginIp = currentLoginIp;
	}

	@Column(name = "LOGIN_COUNT")
	public Long getLoginCount() {
		return this.loginCount;
	}

	public void setLoginCount(Long loginCount) {
		this.loginCount = loginCount;
	}

	@Column(name = "STATE", nullable = false, length = 2)
	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

	/*@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userT")
	public Set<ArticleT> getArticleTs() {
		return this.articleTs;
	}

	public void setArticleTs(Set<ArticleT> articleTs) {
		this.articleTs = articleTs;
	}*/

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "userT")
	public UserRoleT getUserRoleT() {
		return this.userRoleT;
	}

	public void setUserRoleT(UserRoleT userRoleT) {
		this.userRoleT = userRoleT;
	}

	/*@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userT")
	public Set<CommentT> getCommentTs() {
		return this.commentTs;
	}

	public void setCommentTs(Set<CommentT> commentTs) {
		this.commentTs = commentTs;
	}*/

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userT")
	public Set<UserInfoT> getUserInfoTs() {
		return this.userInfoTs;
	}

	public void setUserInfoTs(Set<UserInfoT> userInfoTs) {
		this.userInfoTs = userInfoTs;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "userT")
	public UserMemberT getUserMemberT() {
		return this.userMemberT;
	}

	public void setUserMemberT(UserMemberT userMemberT) {
		this.userMemberT = userMemberT;
	}

}